/**
 * 
 */
package stc.skymobi.content.store;

import java.util.Arrays;
import java.util.List;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import stc.skymobi.content.ContentStore;


/**
 * @author hp
 *
 */
public class CopyContent {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
        AbstractApplicationContext ctx = new ClassPathXmlApplicationContext(
            	"com/skymobi/content/store/copyContentServices.xml");
        ContentStore	src = (ContentStore)ctx.getBean("src");
        ContentStore	dest = (ContentStore)ctx.getBean("dest");
        
        List<String> keys = src.getKeys();
        
        int count = 0;
        for ( String key : keys ) {
        	System.out.println("[" + count + "]begin copy " + key);
        	byte[] content = src.fetch(key);
        	dest.store(content);
        	byte[] fetched = dest.fetch(key);
        	System.out.println("[" + count + "] copy " + key + " " + Arrays.equals(content, fetched));
        	count ++;
        }
    	System.out.println("End of copy.");
	}

}
